package com.choosefine.paycenter.webgateway.pay.web.controller;

import com.choosefine.paycenter.common.dto.JSONResult;
import com.choosefine.paycenter.common.utils.JSONResultGenerator;
import com.choosefine.paycenter.pay.dispatcher.TransferQueryDispatcher;
import com.choosefine.paycenter.pay.dto.TransferQueryDto;
import com.choosefine.paycenter.pay.handler.TransferQueryHandler;
import com.choosefine.paycenter.pay.service.TransferQueryService;
import com.choosefine.paycenter.pay.vo.TransferQueryVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 潘钱钦（qianqinpan@outlook.com）
 * @create 2017-05-11 11:57
 **/
@Api(value = "转账结果查询接口",description = "潘钱钦")
@RestController
@RequestMapping("account/transferquery")
public class TransferQueryController {
    @Autowired
    TransferQueryDispatcher transferQueryDispatcher;

    @PostMapping
    public JSONResult doTransferQuery(@RequestBody TransferQueryDto transferQueryDto){
        TransferQueryHandler transferQueryHandler = transferQueryDispatcher.getTransferQueryHandler(transferQueryDto.getChannel());
        TransferQueryVo transferQueryVo =transferQueryHandler.buildQuery(transferQueryDto);

        return JSONResultGenerator.buildOperSuccessResult(transferQueryHandler.getTransferService().sendTransferQuery(transferQueryVo));

    }
}
